<?php

class CepController extends TMetroUI {
    
    public function listEstado() {
        /* JS */
        $this->HTML->addJavaScript(PATH_TEMPLATE_JS_URL . "jquery/jquery.dataTables.js");
        $this->HTML->addJavaScript(PATH_JS_URL . $this->_controller . "/" . $this->_action . ".js");
        
        /* Criar template */
        $this->TDialog('listEstado');
    } 

    public function listMunicipio() {
        /* JS */
        $this->HTML->addJavaScript(PATH_TEMPLATE_JS_URL . "jquery/jquery.dataTables.js");
        $this->HTML->addJavaScript(PATH_JS_URL . $this->_controller . "/" . $this->_action . ".js");
        
        $objEstadoLogic = new EstadoLogic();
        $objEstado = $objEstadoLogic->obterPorId($this->getParam('idEstado'));
        $this->addDados('estado', $objEstado->getNome());
        
        /* Criar template */
        $this->TDialog('listMunicipio');
    }

    public function listLogradouro() {
        /* JS */
        $this->HTML->addJavaScript(PATH_TEMPLATE_JS_URL . "jquery/jquery.dataTables.js");
        $this->HTML->addJavaScript(PATH_JS_URL . $this->_controller . "/" . $this->_action . ".js");
        
        $objEstadoLogic = new EstadoLogic();
        $objEstado = $objEstadoLogic->obterPorId($this->getParam('idEstado'));
        $this->addDados('estado', $objEstado->getNome());
        unset($objEstadoLogic);
        unset($objEstado);
        
        $objMunicipioLogic = new MunicipioLogic();
        $objMunicipio = $objMunicipioLogic->obterPorId($this->getParam('idMunicipio'));
        $this->addDados('municipio', $objMunicipio->getNome());
        unset($objMunicipioLogic);
        unset($objMunicipio);
        
        
        /* Criar template */
        $this->TDialog('listLogradouro');
    }
    
    public function listLocalidade() {
        /* JS */
        $this->HTML->addJavaScript(PATH_TEMPLATE_JS_URL . "jquery/jquery.dataTables.js");
        $this->HTML->addJavaScript(PATH_JS_URL . $this->_controller . "/" . $this->_action . ".js");
        
        $objMunicipioLogic = new MunicipioLogic();
        $objMunicipio = $objMunicipioLogic->obterPorId($this->getParam('idMunicipio'));
        $this->addDados('municipio', $objMunicipio->getNome());
        unset($objMunicipioLogic);
        unset($objMunicipio);
        
        
        /* Criar template */
        $this->TDialog('listLocalidade');
    } 

}